home *** CD-ROM | disk | FTP | other *** search
/ Singles Flirt Up Your Life! (German) / Singles Flirt Up Your Life.iso / data1.cab / Statemachine / gymMatChar.lua < prev    next >
Text File  |  2004-01-29  |  2KB  |  100 lines

  1. -- mat character state machine
  2. beginStateMachine()
  3.     
  4.     onEnter(function(msg)
  5.         local mat = getStateObjectFromID(msg.sender);
  6.         storeStateObject("mat", mat);
  7.         
  8.         if (mat) then
  9.             -- mat does exist
  10.             if (getParent().isOneActionPointLocked(mat)) then
  11.                 -- action point is locked
  12.                 getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
  13.                 sendMsg("emoThink", getParent().walkSO);
  14.                 exitStateMachine();
  15.             else
  16.                 getParent().lockActionPoints(mat);
  17.             end
  18.         else
  19.             -- mat does not exist anymore
  20.             getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
  21.             sendMsg("emoThink", getParent().walkSO);
  22.             exitStateMachine();
  23.         end
  24.         
  25.         freeHands(getParent());
  26.                 
  27.     end )
  28.     
  29.     onExit(function(msg)
  30. --        local mat = retrieveStateObject("mat");
  31. --        getParent().unlockActionPoints(mat);
  32. --        getParent().stopAllActivities(mat);
  33. --        removeStateObject("mat");
  34.         
  35.         unlockAll("mat");        
  36.         
  37.     end )
  38.     
  39.     state("pushupStart")
  40.     
  41.         onEnter(function(msg)
  42.             startAnimation("pushupDown");
  43.         end )
  44.     
  45.  
  46.         onMsg("end", function(msg)
  47.             
  48.             if testCancel() then
  49.                 setState("pushupEnd");
  50.             else
  51.                 setState("pushupLoop");
  52.             end
  53.         end )    
  54.         
  55.     state("pushupLoop")
  56.     
  57.         onEnter(function(msg)
  58.             local mat = retrieveStateObject("mat");
  59.             local makePushups = getParent().startActivity("makePushups", mat);
  60.             local length, scale = getActivityLength(makePushups);
  61.             scale = scale * 0.5; --make push ups slower
  62.             storeData("scale", scale);
  63.             startAnimation("pushupLoop", false, scale);
  64.             sendDelayedMsgThis("stopPushups", length);
  65.             print("npa length:" .. length);
  66.         end )
  67.     
  68.         onMsg("stopPushups", function(msg)
  69.             local mat = retrieveStateObject("mat");
  70.             getParent().stopActivity("makePushups", mat);
  71.             setState("pushupEnd");
  72.         end )
  73.  
  74.         onMsg("breathe", function(msg)
  75.             getParent().playSound(genderizeReal(getParent(), "atem" .. random(1,2)));
  76.         end )
  77.  
  78.         onMsg("end", function(msg)
  79.             
  80.             if testCancel() or (not getParent().getCurrentActivityGain()) or (getParent().getCondition(NEED_TIREDNESS) < 0.1) then
  81.                 sendMsgThis("stopPushups");
  82.             else
  83.                 startAnimation("pushupLoop", false, retrieveData("scale", 1.0));
  84.                 if (random() < 0.5) then sendMsgThis("breathe"); end;
  85.             end
  86.         end )    
  87.  
  88.     state("pushupEnd")
  89.     
  90.         onEnter(function(msg)
  91.             startAnimation("pushupDown", false, -1);
  92.         end )
  93.     
  94.  
  95.         onMsg("end", function(msg)
  96.             exitAndGoAway();
  97.         end )    
  98.                 
  99. endStateMachine()
  100.